package main

import (
	"os"
	"fmt"
	"net/http"
	"hello-go/service"
)

func main() {
	// 创建一个处理器函数来处理请求
	handler := func(w http.ResponseWriter, r *http.Request) {
		fmt.Printf("requst hello, env:%s\n", os.Getenv("GO_ENV"))
		fmt.Fprintf(w, service.SayHi())
	}
	
	// 注册处理器函数并监听特定的路由
	http.HandleFunc("/hello", handler)

	// 启动服务器并监听端口
	port := ":8080"
	fmt.Printf("Server listening on port %s...\n", port)
	http.ListenAndServe(port, nil)
}